<?php

namespace App\Http\Controllers\Home;

use App\Http\Controllers\Controller;
use \App\Home\Performer;
use Input;
use Auth;

class PerformerController extends Controller
{
    public function index(){
        return view('home.performer.index');
    }

    public function detail(){
        $id = Input::get('id');
        $res = Performer::where('id',$id) -> first() -> toArray();
        $res['is_alias'] == 1 ? $res['performer_name'] = '' : true;
        $res['is_area'] == 1 ? $res['area'] = '火星' : true;
        if($res){
            $data = array(
                'success' => true,
                'resultObject' => $res,
            );
        }else{
            $data = array(
                'success' => false,
            );
        }
        return response() -> json($data);
    }

    //推荐主播列表
    public function listByIndex(){
        $id = Input::get('gid');
        $list = Performer::orderBy('sort','desc') -> select('id','avatar_img','performer_name','alias','is_alias','company','is_area','area','introduce') -> where('is_live','1') -> where('id','<>',$id) -> limit(10) -> get() -> toArray();
        foreach($list as $k => $v){
            $v['is_alias'] == 1 ? $list[$k]['performer_name'] = '' : true;
            $v['is_area'] == 1  ? $list[$k]['area'] = '火星' : true;
        }
        return response() -> json($list);
    }
}